<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <?php
        if(!isset($_SESSION)) session_start();
        
		//unset($_SESSION["roomsData"]);
		unset($_SESSION["rooms"]);
        require('../../Smarty/libs/Smarty.class.php');

        $smarty = new Smarty;

        $smarty->setTemplateDir('./smarty/templates/');
        $smarty->setCompileDir('./smarty/templates_c/');
        $smarty->setConfigDir('./smarty/configs/');
        $smarty->setCacheDir('./smarty/cache/');
        
        //$smarty->setCaching(Smarty::CACHING_LIFETIME_CURRENT);
        
        if(empty($_SESSION['logged_bool'])){
            $_SESSION['logged_bool'] = false;
        }
        $status = $_SESSION['logged_bool'];
        
        if (isset($_SESSION['currentPage'])) {            
            /* Destroy for clean-up reasons */
            unset($_SESSION['currentPage']);
        }
        
        if (isset($_SESSION['login_guard'])) {            
            /* Destroy for clean-up reasons */
            unset($_SESSION['login_guard']);
        }
        
        if (isset($_SESSION['roomsData'])) {
            
            $children = array();
            foreach ($_SESSION['roomsData'] as $roomChidren) {
                $children[] = explode(',', $roomChidren['childrenAge']);
            }
            $smarty->assign("childrenAge", $children);
            $smarty->assign("previousSearch", TRUE);
            $smarty->assign("roomNumber",count($_SESSION['roomsData']));
            $smarty->assign("roomData",$_SESSION['roomsData']);
            
            /* Destroy for clean-up reasons */
            unset($_SESSION['roomsData']);
        } else {
            $smarty->assign("previousSearch", FALSE);
            $smarty->assign("roomNumber", 1);
        }

        $smarty->assign("logged",$status);
        $smarty->display('preHeader.tpl');
        $smarty->assign("menuPage", 'Home');
        echo '<body>';
        $smarty->display('header.tpl');
        $smarty->display('mainPage.tpl');
        $smarty->display('flashyBox.tpl');
        $smarty->display('footer.tpl');
        echo '</body>';
    ?>
</html>